module.exports = function($scope, $modal, $resource, toaster){


    $scope.bigCurrentPage = 1;      //当前页码
	$scope.itemsPerPage = 10;       //每页显示几条

	$scope.countNum = function(){
		$resource('/api/as/puc/subsidycount/getCountForBank', {}, {}).save({'bank':'1'}, function(res){
            if(res.errcode === 0){
				$scope.no_send_money = res.data.no_send_money;
            } else {
                toaster.error({title: '', body: '统计失败'});
            }
        });
	}
	$scope.countNum();
    
    $scope.load = function(pageNo){
        var para = {
            'pageNo': pageNo, 
            'pageSize': $scope.itemsPerPage
        };
        $resource('/api/ac/puc/subsidyCountService/findBankCountList', {}, {}).save(para, function(res){
            if(res.errcode === 0){
				$scope.list = res.data.results;
				$scope.totalItems = res.data.totalRecord;
				$scope.bigCurrentPage = pageNo;
            } else {
                toaster.error({title: '', body: res.errmsg});
            }
        });
	};
	$scope.load(1);

    $scope.gogo = function(obj){
		if(obj.check_status != '1'){
			toaster.error({title: '', body: '审核未通过，无法拨付资金'});
			return;
		}
    	if(confirm('确认发放此项补贴资金吗？')){
			var para = {
				'id': obj.id,
				'company_code': obj.company_code
			}
			$resource('/api/ac/puc/subsidyCountService/setMoneyStatus', {}, {}).save(para, function(res){
				if(res.errcode === 0){
					toaster.success({title: '', body: res.data.msg});
					$scope.load($scope.bigCurrentPage);
					$scope.no_send_money -= obj.actual_money;
				} else {
					toaster.error({title: '', body: res.errmsg});
				}
			});
		}
	};


};